﻿app.factory('ChoresFactory', function ($http, $q) {

    // Repeat of page stuff
    var pagination = {
        page: 0,
        amountPerPage: 5
    }

    // Get all chores
    var getAllChores = function () {
        var def = $q.defer();
        $http({
            method: 'GET',
            url: '/todos',
            //headers: { Authorization: 'Bearer ' + localStorage.getItem('token') }
        }).success(function (data) {
            def.resolve(data);
        }).error(function (data) {
            def.reject(data);
        })
        return def.promise;
    }

    // Get individual chores
    var getUserChores = function (counter) {
        var def = $q.defer();
        $http({
            method: 'GET',
            url: '/UserChores/' + counter
            //headers: { Authorization: 'Bearer ' + localStorage.getItem('token') }
        }).success(function (data) {
            def.resolve(data);
        }).error(function (data) {
            def.reject(data);
        })
        return def.promise;
    }

    return {
        getAllChores: getAllChores,
        getUserChores: getUserChores
    }
})